#ifndef FWS_H_
#define FWS_H_

enum FWS_releaseOptions {
	FWS_CFG_NOT_SET = 0x00,
	FWS_CFG_CROSS_ZONE_1_AND_2__OFF = 0x00,
	FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1__OFF = 0x00,
	FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2__OFF = 0x00,
	FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT__OFF = 0x00,
	FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0__OFF = 0x00,  //
	FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0__OFF = 0x00,
	FWS_CFG_ONESHOT_DETECTION_ZONE_1__OFF = 0x00,
	FWS_CFG_ONESHOT_MCP__OFF = 0x00,

	FWS_CFG_CROSS_ZONE_1_AND_2 = 0x01,
	FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_1 = 0x02,
	FWS_CFG_PRE_RELEASE_DELAY_DETECTION_ZONE_2 = 0x04,
	FWS_CFG_PRE_RELEASE_DELAY_MANUAL_CALLPOINT = 0x08,
	FWS_CFG_INPUT_CANCEL_1_LOCKOFF_0 = 0x10,  //
	FWS_CFG_INPUT_EXTRA_RELEASE_1_ABORT_0 = 0x20,
	FWS_CFG_ONESHOT_DETECTION_ZONE_1 = 0x40,
	FWS_CFG_ONESHOT_MCP = 0x80
};
enum FWS_lockOffCancel {
	FWS_lockoff=0,
	FWS_cancel=1
};
enum FWS_abortExtraRelease {
	FWS_abort=0,
	FWS_extraRelease=1
};
enum FWS_State {
	FWS_STATE_NULL,
	FWS_STATE_STANDBY,  			//x
	FWS_STATE_PRE_RELEASE,			//x
	FWS_STATE_STARTUP,
	FWS_STATE_FIRST_DUMP_ON,
	FWS_STATE_DUMP_ON,
	FWS_STATE_DUMP_OFF,
	FWS_STATE_PAUSE,
	FWS_STATE_RESET_ON,
	FWS_STATE_RESET_OFF,
	FWS_STATE_ABORT,				//x
	FWS_STATE_ABORT_WAIT_RELEASED,	//x
	FWS_STATE_ABORT_TIMER,			//x
	FWS_STATE_NO_WATER,
	FWS_STATE_WAIT_FOR_NEXT_ALARM,
	FWS_STATE_CANCEL,				//x
	FWS_STATE_LOCKOFF				//x
};
enum FWS_OutputCfgMask {
	FWS_OUT_CFG_NONE = 0x00,
	FWS_OUT_CFG_SO_1 = 0x01,
	FWS_OUT_CFG_SO_2 = 0x02,
	FWS_OUT_CFG_SO_3 = 0x03,
	FWS_OUT_CFG_SO_4 = 0x04,
	FWS_OUT_CFG_RL_1 = 0x05,
	FWS_OUT_CFG_RL_2 = 0x06,
	FWS_OUT_CFG_RL_3 = 0x07,
	FWS_OUT_CFG_RL_4 = 0x08,
	FWS_OUT_CFG_RL_5 = 300
};
enum FWS_Output {
	FWS_OUT_BEGIN,
	FWS_OUT_HP_SOL=FWS_OUT_BEGIN,
	FWS_OUT_LP_SOL,
	FWS_OUT_PRE_REL_ANNUN,
	FWS_OUT_REL_ANNUN,
	FWS_OUT_SHUTDOWN,
	FWS_OUT_RESET,
	FWS_OUT_RELEASE_MODE,
	FWS_OUT_END=FWS_OUT_RELEASE_MODE,
	FWS_OUT_COUNT
};
enum FWS_Sector {
	FWS_SECTOR_BEGIN=0,
	FWS_SECTOR_1=0,
	FWS_SECTOR_2=1,
	FWS_SECTOR_3=2,
	FWS_SECTOR_4=3,
	FWS_SECTOR_5=4,
	FWS_SECTOR_6=5,
	FWS_SECTOR_7=6,
	FWS_SECTOR_8=7,
	FWS_SECTOR_END = FWS_SECTOR_8,
	FWS_SECTOR_COUNT = 8
};
enum FWS_Status {
	FWS_INACTIVE = 0,
	FWS_ACTIVE = 1
}__attribute__((aligned(1),packed));
enum FWS_InputCfgMask {
	FWS_INP_CFG_NONE = 0x00,
	FWS_INP_CFG_SI_1 = 0x01,
	FWS_INP_CFG_SI_2 = 0x02,
	FWS_INP_CFG_SI_3 = 0x03,
	FWS_INP_CFG_SI_4 = 0x04,
	FWS_INP_CFG_SI_5 = 0x05,
	FWS_INP_CFG_SI_6 = 0x06,
	FWS_INP_CFG_SI_7 = 0x07,
	FWS_INP_CFG_SI_8 = 0x08,
	FWS_INP_CFG_SI_9 = 0x11,
	FWS_INP_CFG_SI_10 = 0x12,
	FWS_INP_CFG_SI_11 = 0x13,
	FWS_INP_CFG_SI_12 = 0x14,
	FWS_INP_CFG_SZ_1 = 0x15,
	FWS_INP_CFG_SZ_2 = 0x16,
	FWS_INP_CFG_SZ_3 = 0x17,
	FWS_INP_CFG_SZ_4 = 0x18,
	FWS_INP_CFG_SZ_5 = 0x19,
	FWS_INP_CFG_SZ_6 = 0x1A,
	FWS_INP_CFG_SZ_7 = 0x1B,
	FWS_INP_CFG_SZ_8 = 0x1C,
	FWS_INP_CFG_SZ_9 = 0x1D,
	FWS_INP_CFG_SZ_10 = 0x1E,
	FWS_INP_CFG_SZ_11 = 0x1F,
	FWS_INP_CFG_SZ_12 = 0x20
};
enum FWS_Input {
	FWS_INP_BEGIN,
	FWS_INP_DET_ZONE_1=FWS_INP_BEGIN,
	FWS_INP_DET_ZONE_2,
	FWS_INP_MCP,
	FWS_INP_LOCKOFF, //_CANCEL
	FWS_INP_CANCEL,
	FWS_INP_ABORT, // _RELEASE
	FWS_INP_EXTRA_RELEASE,
	FWS_INP_END=FWS_INP_EXTRA_RELEASE,
	FWS_INPUT_COUNT
};
enum FWS_Timers {
	FWS_TMR_PreReleaseTimer,
	FWS_TMR_Abort,
	FWS_TMR_Startup,
	FWS_TMR_DumpOn,
	FWS_TMR_DumpOff,
	FWS_TMR_Pause,
	FWS_TMR_Reset,
	FWS_TMR_C1Counter,
	FWS_TMR_C2Counter,
	FWS_TMR_Interlock,
	FWS_TMR_FirstDumpOn,
	FWS_TMR_NONE
};
enum FWS_inputObjectType {FWS_T_SI, FWS_T_SZ, FWS_T_NULL};

void FWS_init(void);
void FWS_thread(void);

enum FWS_Status FWS_getOutputStatus(enum FWS_Sector sector, enum FWS_Output output);
enum FWS_OutputCfgMask FWS_getOutputCfg(enum FWS_Sector, enum FWS_Output);
enum SO_objectType FWS_getOutputCfgType(enum FWS_Sector sector, enum FWS_Output output);
enum SO_objectNumber FWS_getOutputCfgNum(enum FWS_Sector sector, enum FWS_Output output);
void FWS_getOutputCfgAll(enum FWS_Sector sector, enum FWS_Output output, enum FWS_OutputCfgMask *pcfg, enum SO_objectType *pobjType, enum SO_objectNumber *pnum);

enum FWS_Status FWS_getSectorStatus(enum FWS_Sector);
enum FWS_State FWS_getSectorState(enum FWS_Sector);

enum FWS_Status FWS_getInputStatus(enum FWS_Sector, enum FWS_Input);
enum FWS_Status FWS_getInputPhyStatus(enum FWS_Sector, enum FWS_Input);
enum SI_ADC_STATE FWS_getInputPhyAdcStatus(enum FWS_Sector sector, enum FWS_Input input);

enum FWS_InputCfgMask FWS_getInputPhyCfg(enum FWS_Sector, enum FWS_Input);
enum FWS_inputObjectType FWS_getInputPhyCfgType(enum FWS_Sector, enum FWS_Input);
enum SI_X FWS_getInputPhyCfgNum(enum FWS_Sector, enum FWS_Input);

//void FWS_test_forceInput(enum FWS_Sector sector, enum FWS_Input zone, enum SI_ADC_STATE value);


#endif /* FWS_H_ */
